<template>
  <div>
    <a-table rowKey="id" :columns="columns" :data-source="dataList" :customRow="onRow" :row-selection="rowSelection" :expandIconColumnIndex="-1" :expandIconAsCell="false" :expandedRowKeys="expandedRowKeys">
      <a slot="action" href="javascript:;">Delete</a>
      <div slot="expandedRowRender" slot-scope="record" style="marginLeft: 60px;">
        <span @click="onDetail(record)">详情</span>
      </div>
    </a-table>
  </div>
</template>

<script>
export default {
  computed: {
    rowSelection () {
      return {
        onChange: (selectedRowKeys, selectedRows) => {
          console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
        },
        getCheckboxProps: record => ({
          props: {
            disabled: record.name === 'Disabled User', // Column configuration not to be checked
            name: record.name,
          },
        }),
      };
    },
  },
  data () {
    const columns = [
      { title: 'Name', dataIndex: 'name' },
      { title: 'Age', dataIndex: 'age' },
      { title: 'Address', dataIndex: 'address' },
      { title: 'Action', dataIndex: '', scopedSlots: { customRender: 'action' } },
    ];
    const dataList = [
      {
        id: 1,
        name: 'John Brown',
        age: 32,
        address: 'New York No. 1 Lake Park',
        description: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',
      },
      {
        id: 2,
        name: 'Jim Green',
        age: 42,
        address: 'London No. 1 Lake Park',
        description: 'My name is Jim Green, I am 42 years old, living in London No. 1 Lake Park.',
      },
      {
        id: 3,
        name: 'Joe Black',
        age: 32,
        address: 'Sidney No. 1 Lake Park',
        description: 'My name is Joe Black, I am 32 years old, living in Sidney No. 1 Lake Park.',
      },
    ];
    return {
      columns,
      dataList,
      expandedRowKeys: []
    }
  },
  methods: {
    onRow (record) {
      return {
        on: {
          mouseover: () => {
            console.log(record);
            this.expandedRowKeys = [record.id]
          }
        }
      }
    },
    onDetail (record) {
      console.log(record)
    }
  },
  created () {
  },
}
</script>

<style lang="less" scoped>
.report_page {
  width: 100%;
}
.dict_panes {
  display: flex;
  flex-wrap: wrap;
  .dict_item {
    width: 20%;
    // flex: 1;
    margin-bottom: 40px;

    .dict_title {
      font-size: 12px;
      color: #adadad;
    }
    .dict_data {
      font-size: 24px;
      color: #282828;
      font-weight: bold;
    }
  }
}
</style>